/**
 * Created by Administrator on 2017/1/16 0016.
 */

var islogin = 1;

$(function () {
    $(".left-nav-item").eq(0).click(function () {
        window.location.href = "card_pc.html";
    });
    $(".left-nav-item").eq(1).click(function () {
        window.location.href = "apply.record_pc_student.html";
    });
    $(".return").click(function () {
        window.location.href = "apply.record_pc_student.html";
    });
    $(".exit-btn").click(function () {
        $.ajax({
            url: "/door/StudentFront/exit?" + new Date().getTime(),
            async: false,
            success: function (){
                window.location.href = "login_pc_student.html";
            }
        });
    });
    init();
});

function init() {
    $.ajax({
        url: "/door/StudentFront/getCurStu?" + new Date().getTime(),
        async: false,
        success: function (str) {
            if (checkReturn(str)) {
                $("#stu_name").text(str.name);
                $("#class_name").text(str.classname);
            }
        }
    });
}

function checkReturn(str) {
    if (str != null && str != "") {
        if (str.errorcode != undefined) {
            if (str.errorcode == 1) {
                if (islogin == 1) {
                    layer.msg(str.errormessage, {time: 1000});
                    window.location.href = "login_pc_student.html";
                    islogin = 0;
                }
            }
            if (str.errorcode == 0) {
                return true;
            }
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}